feat(otel): otel sampling support in distributed tracing - #10117
feat(otel): otel sampling support in distributed tracing#10117vpellan wants to merge 46 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Overall package sizeSelf size: 8.87 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.4.0 | 127.33 kB | 447.04 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49eb6259f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
BenchmarksBenchmark execution time: 2026-09-09 14:47:06 Comparing candidate commit 79fa291 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2292 metrics, 21 unstable metrics.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42005a60a5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
# Conflicts: # .github/CODEOWNERS # packages/dd-trace/src/opentracing/propagation/text_map.js # packages/dd-trace/test/opentracing/propagation/text_map.spec.js
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 660cb44f39
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10117 +/- ##
===========================================
+ Coverage 87.23% 98.68% +11.44%
===========================================
Files 996 1008 +12
Lines 153441 158648 +5207
Branches 74 74
===========================================
+ Hits 133857 156562 +22705
+ Misses 19584 2086 -17498
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Guard own-property checks with cheap membership probes so ordinary tag maps avoid three Object.hasOwn calls while inherited sampling tags remain ignored.\n\nNode 24 finish-immediately-with-tags versus the previous implementation: throughput +10.77%, user CPU -8.45%. Versus the exact master baseline: throughput -0.04%, user CPU -0.46%.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eef8dcdba6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd8c1925d2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!span) return | ||
|
|
||
| const context = this._getContext(span) | ||
| if (isProductForceKeep(context)) return |
There was a problem hiding this comment.
Preserve inherited product mechanisms before manual overrides
When a standard OTel parent carries dd=s:2;t.dm:-5 or t.dm:-13, _convertOtelContextToDatadog() parses s but initializes _sampling with only the priority, leaving mechanism undefined; this guard therefore fails to recognize the inherited AppSec/AI Guard force-keep, and a later manual.drop tag now overwrites it. The fresh evidence beyond the earlier local product-force-keep finding is this standard OTel conversion path, whereas native W3C extraction does populate _sampling.mechanism; preserve t.dm during OTel parent conversion so both single- and batch-tag helpers retain the product decision.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77ef7a56ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| spanContext._ddContext._sampling = { priority: samplingPriority } | ||
| if (samplingMechanism !== undefined) spanContext._ddContext._sampling.mechanism = samplingMechanism |
There was a problem hiding this comment.
Preserve the OTel decision-maker trace tag
When a standard OTel parent carries dd=s:2;t.dm:-5, the new serialization path records 5 only in _sampling.mechanism; it never writes _dd.p.dm into _trace.tags because the raw t.dm is copied into span tags instead. Consequently the local trace chunk omits its inherited decision maker, and with Datadog-only injection #injectTags() omits it from x-datadog-tags as well. Fresh evidence after the earlier override fix is that the final assignment here updates only _sampling; preserve the corresponding trace tag as native tracecontext extraction does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I removed this follow-up because preserving _dd.p.dm in Datadog-native trace tags is outside the distributed ot.th/ot.rv scope.
| if (selectedPriority === undefined) { | ||
| selectedSpanContext._sampling.priority = w3cSpanContext._sampling.priority | ||
| selectedSpanContext._sampling.mechanism = w3cSpanContext._sampling.mechanism | ||
| selectedSpanContext._trace.tags['_dd.p.dm'] = w3cSpanContext._trace.tags['_dd.p.dm'] |
There was a problem hiding this comment.
Copy W3C decision metadata when B3 already has a priority
When B3 wins extraction and supplies sampled=1 or sampled=0, selectedPriority is already defined, so an agreeing same-trace W3C context's mechanism and _dd.p.dm are not copied. The W3C tracestate is still forwarded, but the local trace chunk and any Datadog-only downstream injection lose the inherited decision maker. Fresh evidence after the missing-priority fix is that this branch copies the metadata only for undefined priorities; agreeing defined priorities need the same metadata merge.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I removed this follow-up because agreeing B3/W3C contexts already retain the raw ot tracestate without copying Datadog-only decision metadata.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b99215db84
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca108b1856
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
What does this PR do?
Add support for OTel sampling in distributed tracing, by reading and emitting
ot.thandot.rvtags. These tags will be forwarded to services using OTel SDKs, that should forward them to the backend.Motivation
Distributed tracing will work between DD-instrumented services and OTel-instrumented services, downstream OTel services will be able to forward the
thfield it to the collector and backend, which will calculate metrics correctlyAdditional Notes
Locally passes DataDog/system-tests#7518